<?php
html::printPath(
    array('myRegistration.form-title' => '/user/myRegistration/all', 'myRegistration.displayPage-title' => ''),
    'myRegistration.displayPage-desc'
);
$msg->printMessages();

$urlIdParam = $registration['type'] . '=' . $registration['id'];
echo '<ul class="commandList" style="margin-top: 0.5em">';
// echo '<li class="editLi">' . html::anchor('/user/myRegistration/edit?' . $urlIdParam, text::get('myRegistration.editThis')) . '</li>';
if (registrationUtils::canBeCancelled($registration, $viSeminar)) {
    echo '<li class="deleteLi"><a href="#" onclick="return openInDialog(\'cancellationDialog\', \'' . text::getEscaped('myRegistration.cancellation') . '\');">' . text::getEscaped('myRegistration.cancellation') . '</a></li>';
}
else if (date::isInPast($viSeminar['begin_date'], $viSeminar['begin_time'])) {
    if (date::isInPast($viSeminar['end_date'], $viSeminar['end_time'])) {
        echo text::getEscaped('myRegistration.cannotBeCancelled-seminarFinished');
    }
    else {
        echo text::getEscaped('myRegistration.cannotBeCancelled-seminarRunning');
    }
}
echo '</ul>';

// Cancellation dialog
echo '<div id="cancellationDialog" class="hidden">';
echo form::open('/user/myRegistration/cancelViRegistration');
echo form::hidden('id', $registration['id']);
// If the registration is already paid, the money will be returned.
echo '<p>' . text::getEscaped('myRegistration.returnMoneyIfCancelled') . '</p>';
// If the registration is not paid yet, just cancel it.
if (! $registration['paid_price']) {
    echo '<p>' . text::getEscaped('myRegistration.regIsNotPaidYet') . '</p>';
}
echo '<p class="centered"><button type="submit">' . text::getEscaped('myRegistration.cancelThis') . '</button></p>';
echo form::close();
echo '</div>';

echo '<ul>';
echo '<li>' . text::getEscaped('myRegistration.createDateTime') . ': ' . format::timestamp($registration['created_at']) . '</li>';
if ($registration['cancelled_at']) {
    echo '<li><span class="regIsCancelled">' . text::getEscaped('myRegistration.regIsCancelled', format::timestamp($registration['cancelled_at'])) . '</span></li>';
}
if ($registration['paid_price']) {
    // echo '<li>' . text::getEscaped('viRegistration.payment_received_at') . ': ' . format::dateAndTime($registration['payment_date'], $registration['payment_time']) . '</li>';
}
echo '<li>';
if ($registration['is_present']) {
    echo text::getEscaped('myRegistration.participantIsPresent');
}
else {
    echo text::getEscaped('myRegistration.participantIsNotPresent');
}
echo '</li>';
echo '</ul>';

$viRegistrationInfo = new View('/user/viregWizard/fragments/viRegistrationInfo');
$viRegistrationInfo->render(true);